<%- model_class = Campaign -%>

<% @page_title = "Phishing Campaigns" %>

<div class="page-header">
  <h2>Campaigns</h2>
</div>

<!-- Button trigger modal -->
<div id="campaign-buttons">
  <button class="btn btn-primary" data-toggle="modal" data-target="#createCampaign">
    New Campaign
  </button>
</div>

<table id="campaigns" class="table table-striped table-hover table-condensed display" summary="Campaign list">
  <thead>
    <tr class="header">
      <th></th>
      <th>Client</th>
      <th>Owner</th>
      <th>Active</th>
      <th>Emails</th>
      <th>Actions</th>
    </tr>
  </thead>
  <tbody>
    <% @campaigns.each do |campaign| %>
    
    <tr>
      <td><%= campaign.decorate.campaign_icon %></td>      
      <td><%= campaign.name %></td>
      <td><%= campaign.decorate.owner %></td>
      <td><%= campaign.decorate.active_icon %></td>
      <td><%= campaign.decorate.emails_icon %></td>
      <td class="actions">
        <div id="actions-buttons">
          <%= link_to("<span class='glyphicon glyphicon-search'></span>".html_safe,
                campaign_path(campaign.id), data: {placement: 'bottom'},
                class: 'btn btn-default btn-xs', rel: 'tooltip',
                title: 'Campaign Options') %>
          <%= link_to("<span class='glyphicon glyphicon-retweet'></span>".html_safe,
                copy_campaign_path(campaign.id), data: {placement: 'bottom'},
                class: 'btn btn-default btn-xs', rel: 'tooltip',
                title: 'Copy Campaign', method: :post) %>
          <%= link_to "<span class='glyphicon glyphicon-remove'></span>".html_safe,
                campaign_path(campaign), method: :delete,
                data: { confirm: 'Are you sure you want to permanently delete this campaign?', placement: 'bottom'}, rel: 'tooltip',
                class: 'btn btn-danger btn-xs',
                title: 'Delete Campaign' %>
        </div>
      </td>
    </tr>
    <% end %>
  </tbody>
</table>
</div>
<hr>

<!-- Modal -->
<div class="modal fade" id="createCampaign" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h4 class="modal-title" id="myModalLabel">New Phishing Campaign</h4>
    </div>
    <div class="modal-body">
      <%= render partial: 'new' %>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
  </div>
</div>
